<?php

declare(strict_types=1);

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;

class Influencer extends Model
{
    use HasFactory, SoftDeletes;

    /**
     * 可批量赋值的属性
     *
     * @var array<string>
     */
    protected $fillable = [
        'name',
        'platform_id',
        'platform_user_id',
        'avatar',
        'description',
        'contact_info',
        'follower_count',
        'score',
        'report_count',
        'is_blacklisted',
    ];

    /**
     * 应该被转换为原生类型的属性
     *
     * @var array<string, string>
     */
    protected $casts = [
        'follower_count' => 'integer',
        'score' => 'decimal:1',
        'report_count' => 'integer',
        'is_blacklisted' => 'boolean',
    ];

    /**
     * 获取该网红所属的平台
     */
    public function platform(): BelongsTo
    {
        return $this->belongsTo(Platform::class);
    }

    /**
     * 获取该网红的所有举报记录
     */
    public function reports(): HasMany
    {
        return $this->hasMany(Report::class);
    }
} 